from tabnanny import verbose
from django.db import models
from app.models import BaseModel
# Create your models here.

from datetime import datetime


def get_week():
    now = datetime.now()
    return int(now.strftime("%V"))  # 返回字符串，如 "14"


class Journal(BaseModel):

    LEVEL_CHOICES = [
        ('S', 'Study'),  # 学习
        ('W', 'Work'),  # 工作
        ('L', 'Life'),    # 生活
    ]
    project_ids = models.CharField(
        verbose_name='项目IDS', db_comment='项目IDS', max_length=50, null=True, blank=True)
    log_date = models.DateTimeField(
        verbose_name='日志日期', db_comment='日志日期', default=datetime.now)
    week = models.IntegerField(
        verbose_name='第几周', db_comment='第几周', default=get_week())

    category = models.CharField(
        max_length=1,
        choices=LEVEL_CHOICES,
        default='W',
        verbose_name='日志类型', db_comment='日志类型'
    )
    today_work = models.TextField(
        verbose_name='今天的工作', db_comment='今天的工作', null=True, blank=True)
    tomorrow_plan = models.TextField(
        verbose_name='明天的计划', db_comment='明天的计划', null=True, blank=True)
    summary = models.TextField(
        verbose_name='总结', db_comment='总结', null=True, blank=True)
    ai_summary_and_suggestions = models.TextField(
        verbose_name='AI总结及建议', db_comment='AI总结及建议', null=True, blank=True)

    def __str__(self):
        return f"第{self.week}周记录" or ''

    class Meta:
        db_table = 'journal_log'
        verbose_name = '工作记录'
        verbose_name_plural = '02.工作记录'
        db_table_comment = '工作记录表'


class Project(BaseModel):
    name = models.CharField(
        verbose_name='项目名称', db_comment='项目名称', max_length=255, null=True, blank=True)
    description = models.TextField(
        verbose_name='项目描述', db_comment='项目描述', null=True, blank=True)
    todo_list = models.TextField(
        verbose_name='待办列表', db_comment='待办列表', null=True, blank=True)

    def __str__(self):
        return self.name or ''

    class Meta:
        db_table = 'journal_project'
        verbose_name = '项目'
        verbose_name_plural = '01.项目'
        db_table_comment = '工作项目表'
